﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Model.EntityModel;

namespace Project
{
    /// <summary>
    /// Interaction logic for PrintDirectAction.xaml
    /// </summary>
    public partial class PrintDirectAction : UserControl
    {
        DirectAction direct = new DirectAction();
        InterveningPolice officer = new InterveningPolice();
        Complaint complaint = new Complaint();       
        Actor actorComplainant = new Actor();        
        Person complainant = new Person();
        long idComplaint;

        public PrintDirectAction(long idCom)
        {
            InitializeComponent();
            try
            {
                idComplaint = idCom;
                lblCaseNumber.Content = idComplaint;
                ChargeFact();
                ChargeOffice();
                ChargeComplainant();
            }
            catch
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("La denuncia no tiene registrada accion directa", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }

        private void ChargeComplainant()
        {
            actorComplainant = DataAccess.PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Denunciante", idComplaint);
            complainant = DataAccess.PersonAndActorDataAccess.GetPersonById(actorComplainant.IdPerson);
            TxtBoxComplainantCI.Content = complainant.CiPassport.ToString();
            TxtBoxComplainantName.Content = complainant.Name;
            TxtBoxComplainantPN.Content = complainant.PaternalName;
            TxtBoxComplainantMN.Content = complainant.MaternalName;
            TxtBoxComplainantOccupation.Content = complainant.Ocupation;
            comboBoxComplainantMaritalStatus.Content = complainant.CivilStatus;
            TxtBoxComplainantBornPlace.Content = complainant.BornCity;
            TxtBoxComplainantAddress.Content = complainant.Address;
            TxtBoxComplainantZone.Content = complainant.Zone;
            TxtBoxComplainantPhone.Content = complainant.Phone;
            datePickerBirthDateCamplainant.Content = complainant.BirthDate.ToString();

        }

        

        private void ChargeOffice()
        {
            officer.CI = Convert.ToInt64(direct.CIInterveningPolice);
            officer = DataAccess.InterveningPoliceDataAccess.GetPoliceByCi(officer.CI);
            TxtBoxOfficeCI.Content = officer.CI.ToString();
            TxtBoxOfficeName.Content = officer.Name;
            TxtBoxOfficePN.Content = officer.PaternalName;
            TxtBoxOfficeMN.Content = officer.MaternalName;
            TxtBoxOfficeDepartament.Content = officer.PoliceStation;
            TxtBoxOfficeZone.Content = officer.Zone;
            TxtBoxOfficeWorkPlace.Content = officer.Place;
            comboBoxOfficeRank.Content = officer.Rank;
        }

        private void ChargeFact()
        {
            complaint = DataAccess.ComplaintDataAccess.GetComplaintById(idComplaint);
            lblCaseDate.Content = DateTime.Now.Date;
            TxtBoxFactPlace.Content = complaint.IncidentPlace;
            TxtBoxFactZone.Content = complaint.IncidentZone;
            datePickerFactDate.Content = complaint.IncidentDate.ToString();
            direct.Id = Convert.ToInt64(complaint.IdDirectAction);
            direct = DataAccess.DirectActionDataAccess.GetDirectActionById(direct.Id);
            cmbBoxHours.Content = direct.IncidentTime.ToString();
            TxtBoxFactNature.Content = direct.IncidentNature;
            
        }
    }
}
